#include<stdio.h>

int main(void)
{
	int n,num1=0,num2=0,score;
	double total=0,point;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lf%d",&point,&score);
		if(score<30)
		{
			num1++;
			total+=point;
		}
		else if(score<60)
		{
			num2++;
			total+=point;
		}
	}
	printf("%d %d %.1lf",num1,num2,total);
	return 0;
}
